package net.narusas.aceauction.push;

import java.util.List;

import net.narusas.aceauction.push.model.Device;

import lombok.Data;

@Data
public class PushServiceGateway implements PushService {
	APSNPushService apsnPushService;
	C2DMPushService c2dmPushService;

	@Override
	public void pushText(Device device, String message) {
		if (device == null || message == null) {
			return;
		}
		if (device.isIOSDevice()) {
			apsnPushService.pushText(device, message);
		}
		if (device.isAndroidSDevice()) {
			c2dmPushService.pushText(device, message);
		}
	}

	@Override
	public void pushText(List<Device> devices, String message) {
		apsnPushService.pushText(devices, message);
		c2dmPushService.pushText(devices, message);
	}

	@Override
	public void pushBadge(Device device, int badgeCount) {
		if (device == null || device.isReady() == false || device.isSendable() == false) {
			return;
		}
		if (device.isIOSDevice()) {
			apsnPushService.pushBadge(device, badgeCount);
		}
		if (device.isAndroidSDevice()) {
			c2dmPushService.pushBadge(device, badgeCount);
		}
	}

}
